package com.xujie.sportsmeeting.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 奖牌统计VO
 */
@Data
@Schema(description = "奖牌统计信息")
public class MedalStatisticsVO {

    @Schema(description = "排名")
    private Integer ranking;

    @Schema(description = "团体名称")
    private String teamName;

    @Schema(description = "院系名称")
    private String department;

    @Schema(description = "班级名称")
    private String className;

    @Schema(description = "金牌数")
    private Integer goldMedals;

    @Schema(description = "银牌数")
    private Integer silverMedals;

    @Schema(description = "铜牌数")
    private Integer bronzeMedals;

    @Schema(description = "总奖牌数")
    private Integer totalMedals;

    @Schema(description = "总得分")
    private BigDecimal totalScore;

    @Schema(description = "参赛人数")
    private Integer participantCount;

    @Schema(description = "获奖率")
    private BigDecimal medalRate;

    @Schema(description = "奖牌效率")
    private BigDecimal medalEfficiency;

    @Schema(description = "与上名差距")
    private Integer medalGap;

    @Schema(description = "排名变化")
    private Integer rankingChange;

    @Schema(description = "排名变化描述")
    private String rankingChangeText;

    // 获取总奖牌数
    public Integer getTotalMedals() {
        int total = 0;
        if (goldMedals != null) total += goldMedals;
        if (silverMedals != null) total += silverMedals;
        if (bronzeMedals != null) total += bronzeMedals;
        return total;
    }

    // 获取排名展示文本
    public String getRankingText() {
        if (ranking == null || ranking <= 0) return "";
        
        switch (ranking) {
            case 1: return "🥇 冠军";
            case 2: return "🥈 亚军";
            case 3: return "🥉 季军";
            default: return "第" + ranking + "名";
        }
    }

    // 获取排名变化描述
    public String getRankingChangeText() {
        if (rankingChange == null || rankingChange == 0) return "—";
        if (rankingChange > 0) return "↑" + rankingChange;
        return "↓" + Math.abs(rankingChange);
    }

    // 获取奖牌分布文本
    public String getMedalDistributionText() {
        return String.format("🥇%d 🥈%d 🥉%d", 
                goldMedals != null ? goldMedals : 0,
                silverMedals != null ? silverMedals : 0,
                bronzeMedals != null ? bronzeMedals : 0);
    }
}
